package com.sayice.robotconflict.config;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.mongodb.core.convert.DefaultMongoTypeMapper;
import org.springframework.data.mongodb.core.convert.MappingMongoConverter;

/**
 * MongoDB 配置
 *
 * @author shubing
 */
@Configuration
public class MongoConfig implements InitializingBean {
    @Autowired
    private MappingMongoConverter mappingMongoConverter;
    
    @Override
    public void afterPropertiesSet() {
        // 插入时不添加 _class 字段
        mappingMongoConverter.setTypeMapper(new DefaultMongoTypeMapper(null));
    }
}
